package com.xja.food.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xja.food.entity.Food;
import com.xja.food.mapper.FoodMapper;
import com.xja.food.service.FoodService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

@Service
public class FoodServiceImpl implements FoodService {

    Logger logger = LoggerFactory.getLogger(FoodServiceImpl.class);

    @Autowired
    private FoodMapper foodMapper;

    @Transactional(readOnly = true)
    @Override
    public List<Food> foodList() {
        return foodMapper.foodList();
    }

    @Override
    public void addFood(Food food) {
        logger.info("添加");
        foodMapper.insert(food);
    }
@Transactional(propagation = Propagation.REQUIRED)
    @Override
    public void deleteFood(Integer fid) {
        foodMapper.deleteById(fid);
    }

    @Override
    public Food selectFoodById(Integer fid) {
        return foodMapper.selectByFid(fid);
    }

    @Override
    public void updatefood(Food food) {
        foodMapper.updatefood(food);
    }

}


